package com.study.hadoop.mapreduce.reduceJoin;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

/**
 * @Author huang
 * @Date 2022/1/14 14:10
 * @Version 1.0
 */
public class TableDriver {
    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        /*Job job = Job.getInstance(new Configuration());

        job.setJarByClass(TableDriver.class);
        job.setMapperClass(TableMapper.class);
        job.setReducerClass(TableReducer.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(TableBean.class);

        job.setOutputKeyClass(TableBean.class);
        job.setOutputValueClass(NullWritable.class);

        FileInputFormat.setInputPaths(job,new Path("D:\\生活\\study\\hadoop\\资料\\11_input\\inputtable"));
        FileOutputFormat.setOutputPath(job,new Path("D:\\生活\\study\\hadoop\\资料\\11_input\\inputtable\\test"));

        boolean result = job.waitForCompletion(true);

        System.exit(result?0:1);*/


        Job job = Job.getInstance(new Configuration());

        job.setJarByClass(TableDriver.class);
        job.setMapperClass(TableMapper.class);
        job.setReducerClass(TableReducer.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(TableBean.class);

        job.setOutputKeyClass(TableBean.class);
        job.setOutputValueClass(NullWritable.class);

        FileInputFormat.setInputPaths(job, new Path("D:/生活/study/hadoop/资料/11_input/inputtable"));
        FileOutputFormat.setOutputPath(job, new Path("D:/生活/study/hadoop/资料/11_input/inputtable/test"));

        boolean b = job.waitForCompletion(true);
        System.exit(b ? 0 : 1);

    }
}
